
import { _decorator, Component, Node, Sprite, Label, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AwardItem')
export class AwardItem extends Component {
    init(data?) {
        if (!!data) {
            this.setData(data);
        }
    }
    reuse(data?) {
        if (!!data) {
            this.setData(data);
        }
    }
    setData(data) {
        if (data["goodsType"] == "gold") {
            this.spr.spriteFrame = this.imgs[0];
            this.gold.node.active = true;
            this.gold.string = data["value"];
        } else {
            this.gold.node.active = false;
            this.spr.spriteFrame = this.imgs[data["id"] - 5];
        }
    }
    unuse() {

    }

    @property(Sprite)
    spr: Sprite = null;
    @property(Label)
    gold: Label = null;
    @property([SpriteFrame])
    imgs: SpriteFrame[] = [];
}
